/*
The basic logic is simlpe
as both sides are the same "smart"
in two steps , if three in line and both sides
or four in line and not both sides blocked
*/
/*
ps:
as there is only two steps so consider the strategy is simple
only two decisions : attack or defence
attack: lenghten the existed line
defence: block the ends of the outher side
must-defence situtation1:opponent has three in line , both ends clear
must-defence situtation2:opponent has four in line , have end clear
*/
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
// use dfs to check line
int x1,x2[201],y1,y2[201],cnt=0;
char map[20][20];
bool flag[20][20];
int checkmp(int x,int y)
{
    return (x>0 && x<21 && y>0 && y<21);
}
void check_line(int x,int y,char flagc)
{
    if(map[x][y]!=flagc || flag[x][y]==1 || checkmp(x,y))return;
    flag[x][y]=1;
    check_line(x+1,y,flagc);
    check_line(x-1,y,flagc);
    check_line(x,y+1,flagc);
    check_line(x,y-1,flagc);
    if(!flag[x+1][y]&&!flag[x-1][y]&&!flag[x][y+1]&&!flag[x][y-1])
    {
        cnt++;
        x2[cnt]=x;
        y2[cnt]=y;
    }
    return;
}